<?=AZNet::$extraFooter;?>
<?
/*<script type="text/javascript">
jQuery(function(){
    jQuery("img.lazyload").lazyload({
       placeholder : "<?=STATIC_URL?>style/images/spacer.gif"//,effect : "fadeIn"
    });
});
</script>
*/
//Set default debug
if (isset($_GET["ebug"])){
	AZLib::my_setcookie("ebug",(int)(boolean)$_GET["ebug"]);
}
if (isset($_GET["abug"])){
	AZLib::my_setcookie("abug",(int)(boolean)$_GET["abug"]);
}
if (isset($_GET["tbug"])){
	AZLib::my_setcookie("tbug",(int)$_GET["tbug"]);
}

//ob_flush();
//flush();
//Xoá SS của khách vãng lai
/*if( AZLib::session_started() AND (!$_SESSION['user_id']) ){
	session_destroy();
}*/
/*if ( REWRITE_ON){
	$getcontents = ob_get_contents();
	ob_end_clean();	
	@ob_start('ob_gzhandler');
	
	echo AZRewrite::doReplace($getcontents);
	unset($getcontents);
}*/

if(User::is_root()){
?>
<div style="margin:0px;width:99%">
    <table cellpadding="0" cellspacing="0" style="float:left;" width="100%">
        <tr>
            <td>
            	<center>
	            	<hr>
	                    Num query: <?=DB::num_queries()?>
	                    | <a href="<?=Url::build('page')?>">Page list</a> 
	                    | <a href="<?=Url::build('edit_page',array('id'=>AZNet::$page['id']))?>">Bố cục trang</a> 
	                    | <a href="<?=Url::build('page',array('id'=>AZNet::$page['id'],'cmd'=>'edit'))?>">Sửa trang</a>
	                    | <a href="<?=Url::build('page',array('id'=>AZNet::$page['id'],'cmd'=>'refresh','href'=>'?'.$_SERVER['QUERY_STRING']))?>">Xoá cache trang</a>
    		</center>
    </td>
    </tr>
    </table>
</div>
<?
}

global $start_rb;
$mtime 			= microtime();
$mtime 			= explode(" ",$mtime);
$mtime 			= $mtime[1] + $mtime[0];
$end_rb 		= $mtime;			
$page_load_time = round(($end_rb - $start_rb),5)."s";	

$time_now 	= date('H:i:s - d-m-Y', TIME_NOW);
$html_debug 	= CGlobal::$query_debug;
$queries_count 	= DB::num_queries();
$queries_time 	= CGlobal::$query_time;
$conn_debug 	= CGlobal::$conn_debug; 

if(DEBUG){
?>
<style>
.li_debug li{list-style:outside decimal}
</style>
<?
	$sql_load_time = round($queries_time,5) ."s";
	
	echo "<center><div align=\"left\" style=\"background-color:#fff;color:#000;clear:left;width:950px;border:1px red solid;padding-left:30px;padding-bottom:30px;overflow: auto;\">";
	echo "<div style='text-align:center'><span style='color:#444;'>Pageload time : $page_load_time</span></div>";
	echo "<html><head><title>SQL Debugger</title><body bgcolor='white'>";
	echo "<h1 align='center'>SQL Total Time: {$sql_load_time} for {$queries_count} queries</h1>";
	echo "<div style='text-align:center'><span style='color:#666;'>$conn_debug</span></div>";	
	
	if(MEMCACHE_ON)
	{
		echo "<br /><table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>
			 <tr>
				  <td style='font-size:14px' bgcolor='#EFEFEF' align='left'><span style='color:green'><b>MEMCACHE CACHES</b>:</span> get: ".AZMemcache::$get."; miss: ".AZMemcache::$miss."; replace: ".AZMemcache::$replace."; set: ".AZMemcache::$set."; del: ".AZMemcache::$del."</td>
				 </tr>
			</table>";
	}
	
	echo "<br>{$html_debug}";
	
	if(StaticCache::$cacheFilesList!=''){
		echo "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>
			 <tr>
				  <td style='font-size:14px' bgcolor='#EFEFEF' align='center'><span style='color:green'><b>STATIC CACHES</b></span></td>
				 </tr>
				<tr>
			  <td style='font-family:courier, monaco, arial;font-size:14px;color:green'>
			 <ol class='li_debug'> ".StaticCache::$cacheFilesList."</ol>
			  </td>
			 </tr>
			 <tr>
			</table><br />";
	}
	if(AZArrCache::$cache_list!=''){
		echo "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>
			 <tr>
				  <td style='font-size:14px' bgcolor='#EFEFEF' align='center'><span style='color:green'><b>ARRAY CACHES</b></span></td>
				 </tr>
				<tr>
			  <td style='font-family:courier, monaco, arial;font-size:14px;color:green'>
			 <ol class='li_debug'> ".AZArrCache::$cache_list."</ol>
			  </td>
			 </tr>
			 <tr>
			</table><br />\n\n";
	}
	
	if(CGlobal::$error_handle){
		echo "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>
		<tr><td style='font-size:14px' bgcolor='#EFEFEF'  align='center'>Enbac Error handle</td></tr>
		".CGlobal::$error_handle."
		</table><br />\n\n";
	}
	if(AutoLoader::$list_file){
		echo "<table width='95%' border='1' cellpadding='6' cellspacing='0' bgcolor='#FEFEFE'  align='center'>
		<tr><td style='font-size:14px' bgcolor='#EFEFEF'  align='center'><b>EB auto require files</b></td></tr>
			 <td style='font-family:courier, monaco, arial;font-size:14px;color:green'>
			 <ol class='li_debug'>".AutoLoader::$list_file."</ol>
			 </td></tr>
		</table><br />\n\n";
	}
	if(REWRITE_ON)
	{
		echo "<center><div style='width:95%' align='left'><b>Rewriten:</b> ".AZRewrite::$count."</div></center><br />\n\n";
	}
	
	echo "<br /><div align='center'><strong>Pageload time: <span style='color:red'>{$page_load_time}</span> - Total SQL Time: <span style='color:red'>{$sql_load_time}</span> - Total queries : <span style='color:red'>{$queries_count}</span> -  Server IP address : <span style='color:red'>{$_SERVER['SERVER_ADDR']}</span> - Time now is : <span style='color:red'>{$time_now}</span></strong></div></body></html>";
	
	echo "</div>
	</center>";	
	//All error here	
}
else{/*code GA cu*/
?><script type="text/javascript">Mudim.SetMethod(2);</script><?
}
if(ADMICRO_ON){//Đoạn này dùng để hiển thị các box quảng cáo
?>
<script>
jQuery(document).ready(function(){
	setTimeout("jQuery(\"div > .adv_adm\").show();",500);
});
</script>
<?
}
?>
</body></html>